package com.example.capsule_netty.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.capsule_netty.bean.OneToOneMessageBean;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @Author: zhuzhiming
 * @Date: 2022/5/3 23:35
 */
public interface OneToOneMessageMapper extends BaseMapper<OneToOneMessageBean> {
    @Select(value = "select * from one_to_one_message where room_name = #{roomName} ")
    List<OneToOneMessageBean> getMessagesList(String roomName);

    @Update("update one_to_one_message set sign_status = 2 where id = #{id}")
    void recallMessage(int id);

    @Select("select max(id + 0) from one_to_one_message where room_name = #{roomName}")
    int getMaxId( String roomName);

    @Update("update one_to_one_message set sign_status = 1 where room_name = #{roomName} and sign_status = 0")
    void updateMessageStatus(String roomName);

    @Update("truncate table one_to_one_message")
    void truncateTable();
}
